<extend name="Public/base" />

<block name="body">
	<!-- 标题栏 -->
	<div class="main-title">
		<h2>病历列表</h2>
	</div>

    <div class="cf">
        <div class="fl">
            <select style="margin-right: 20px" id="export">
                <option value="">-导出-</option>
                <option value="FILTERED">导出筛选</option>
                <option value="CHECKED">导出勾选</option>
            </select>

        </div>

        <div class="fl">
        <button class="btn bg-light-blue ajax-post confirm" url="{:U('deltet')}" target-form="ids">删 除</button>
    </div>


        <div class="cf">
            <div class="search-form" style="display: flex; align-items: center;">
                <label>医生姓名:</label>
                <input placeholder="姓名" name="name" class="text" value="{:I('name')}" style="margin-left: 20px;width:120px;;">
                <label style="margin-left: 20px;">医院:</label>
                <input placeholder="医院" name="phone" class="text" value="{:I('hospital')}" style="margin-left: 20px;width:150px;">
                <label style="margin-left: 20px;">眼压:</label>
                <input name="yanya_start" class="text" value="{:I('yanya_start')}" style="margin-left: 20px;width:40px;">
                ~
                <input  name="yanya_end" class="text" value="{:I('yanya_end')}" style="width:40px;">
                <label style="margin-left: 20px;">角膜横径:</label>
                <input name="jiaomo_start" class="text" value="{:I('jiaomo_start')}" style="margin-left: 20px;width:40px;">
                ~
                <input  name="jiaomo_end" class="text" value="{:I('jiaomo_end')}" style="width:40px;">
                <label style="margin-left: 20px;">最薄点厚度:</label>
                <input name="bodian_start" class="text" value="{:I('bodian_start')}" style="margin-left: 20px;width:40px;">
                ~
                <input  name="bodian_end" class="text" value="{:I('bodian_end')}" style="width:40px;">
                <label style="margin-left: 20px;">最大曲率:</label>
                <input name="qulv_start" class="text" value="{:I('qulv_start')}" style="margin-left: 20px;width:40px;">
                ~
                <input  name="qulv_end" class="text" value="{:I('qulv_end')}" style="width:40px;">
                <button style="margin-left: 20px" class="btn bg-orange" id="search" url="{:U('index')}">查询</button>
            </div>
        </div>

    </div>

    <!-- 数据列表 -->
    <div class="data-table table-striped">
	<table class="">
    <thead>
        <tr>
		<th class="row-selected row-selected"><input class="check-all" type="checkbox"/></th>
		<th class="">id</th>
        <th class="">编号</th>
		<th class="">病历所属医生</th>
        <th class="">病人姓名</th>
		<th class="">年龄</th>
		<th class="">性别</th>
		<th class="">婚姻状况</th>
		<th class="">职业</th>
		<th class="">籍贯</th>
		<!--<th class="">近视时长</th>-->
        <th class="">创建时间</th>
        <th class="">操作</th>
		</tr>
    </thead>
    <tbody>
		<notempty name="_list">
		<volist name="_list" id="vo">
		<tr>
            <td><input class="ids" type="checkbox" name="id[]" value="{$vo.rid}" /></td>
			<td>{$vo.rid} </td>
            <td>{$vo.id_number} </td>
			<td>{$vo.doctor_name}</td>
            <td>{$vo.name}</td>
			<td>{$vo.age}</td>
			<td>{$vo.sex}</td>
			<td>{$vo.marriage_status}</td>
			<td>{$vo.occupation}</td>
            <td>{$vo.native_place}</td>
            <!--<td>{$vo.myopia_year}</td>-->
			<td><span>{$vo.createdate}</span></td>
			<td>
				<a class="op blue" href="{:U('Record/info&id='.$vo['rid'].'&a=1')}" >病历详情</a>
                <if condition ="$vo['visible'] eq 'Y'">
                    <a href="{:U('Record/hide&id='.$vo['rid'].'&a=1')}" class="confirm ajax-get op light-red">隐藏</a>
                   <else/>
                    <a href="{:U('Record/show&id='.$vo['rid'].'&a=1')}" class="confirm ajax-get op light-blue">显示</a>
                </if>
            <!--    <a data-href="{:U('Record/comment&id='.$vo['id'].'&a=1')}"  class="comment op light-blue">添加评论</a>
                <a data-href="{:U('Record/commentList&id='.$vo['id'].'&a=1')}"  class="detail op light-blue">评论列表</a>-->

              <!--  <a class="blue info" data-name="trade" href="{:U('Record/commentList', ['record_id' => $vo['rid']])}" >评论列表</a>-->
                <a class="blue info" data-name="trade" href="{:U('Record/newCommentList', ['record_id' => $vo['rid']])}" >新评论列表</a>
                <a data-group-name="{$vo['title']}" class="right" href="javascript:" data-href="{:U('Record/getQrcodeUrl?id='.$vo['rid'])}" >打开小程序码链接</a>

        </tr>
		</volist>
		<else/>
		<td colspan="9" class="text-center"> aOh! 暂时还没有内容! </td>
		</notempty>
	</tbody>
    </table>
	</div>
    <div class="page">
        {$_page}
    </div>
</block>

<block name="script">
	<script src="__STATIC__/thinkbox/jquery.thinkbox.js"></script>
    <script src="__STATIC__/layer/layer.js"></script>
	<script type="text/javascript">
	//搜索功能
	$("#search").click(function(){
		var url = $(this).attr('url');
        var query  = $('.search-form').find('input').serialize();
        query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g,'');
        query = query.replace(/^&/g,'');
        if( url.indexOf('?')>0 ){
            url += '&' + query;
        }else{
            url += '?' + query;
        }
		window.location.href = url;
	});
	//回车搜索
	$(".search-input").keyup(function(e){
		if(e.keyCode === 13){
			$("#search").click();
			return false;
		}
	});

    $('a.right').click(function () {
        let url = $(this).attr('data-href')
        $.post(url, {}, function (res) {
            if(res.code == -1){
                layer.msg('获取小程序码链接失败，请重试', {
                    time: 2000
                });
                return
            }else{
                window.open(res.qr_code_url);
/*                let input = document.createElement('input');
                let content = res.qr_code_url
                document.body.appendChild(input);
                input.setAttribute('value', content);
                input.select();
                if (document.execCommand('copy')) {
                    document.execCommand('copy');
                    layer.msg('复制成功');
                }
                document.body.removeChild(input);*/
            }
        });

    })


    $('#export').change(function () {
        var type = $(this).val();
        if (!type) return;
        $(this).val('');
        var ids = [];
        var query = '';
        if (type === 'CHECKED') {
            var ids = [];
            $('.ids:checked').each(function() {
                ids.push($(this).val())
            })
            if (!ids.length) {
                alert('没有勾选');
                return;
            }
        } else if (type === 'FILTERED') {
            query += $('.search-form').find('input,select').serialize();
        }

        window.open('{:U("export")}&type=' + type + '&ids=' + ids + '&' + query);
    });

    //导航高亮
    highlight_subnav('{:U('Member/index')}');
	</script>
</block>
